package main

import (
	"fmt"
	"reflect"
)

type MyInt int

func Print(v interface{}) {
	switch v.(type) {
	case uint32:
		fmt.Println("v.(type) uint32 %d", v)
	case string:
		fmt.Println("v.(type) string %s", v)
	case float64:
		fmt.Println("v.(type) float64 %f", v)
	}
	rv := reflect.ValueOf(v)
	rt := reflect.TypeOf(v)
	//ele := rv.Elem()
	switch tp := rv.Kind(); tp {
	//switch tp := rv.Type(); tp {
	case reflect.Uint32:
		//fmt.Println("Kind:", rv.Kind(), " Value:", rv.Interface().(uint32))
		fmt.Println("Kind:", rv.Kind(), " Value:", uint32(rv.Uint()))
	case reflect.Float64:
		//fmt.Println("Kind:", rv.Kind(), " Value:", rv.Interface().(float64))
		fmt.Println("Kind:", rv.Kind(), " Value:", rv.Float())
	case reflect.String:
		//fmt.Println("Kind:", rv.Kind(), " Value:", rv.Interface().(string))
		//fmt.Println("Kind:", rv.Kind(), " Value:", rv.Interface().(string))
		fmt.Println("Kind:", rv.Kind(), " Value:", rv.String())
	case reflect.Int:
		//fmt.Println("Kind:", rv.Kind(), " Value:", rv.Interface().(int))
		fmt.Println("Kind:", rv.Kind(), " Value:", int(rv.Int()))
	default:
		fmt.Println("Kind:", rv.Kind(), " Type:", rv.Type())
	}
	fmt.Println("Kind:", rv.Kind(), " Type:", rv.Type(), " rt_Kind:", rt.Kind())
	fmt.Println("Kind:", rv.Kind(), " Value:", rv.Interface())
}

func main() {
	var x float64 = 3.4
	//fmt.Println("type:", reflect.TypeOf(x))
	//fmt.Println("value:", reflect.ValueOf(x))
	Print(x)
	fmt.Println("--x--")
	//type MyInt int
	var y MyInt = 7
	Print(y)
	fmt.Println("--y--")
	str := "I Love U"
	Print(str)
	fmt.Println("--str--")
	/*v := reflect.ValueOf(y)
	fmt.Println("value2:", reflect.ValueOf(y))
	fmt.Println("kind:", v.Kind(), " ", v.Type())
	fmt.Println("value2:", reflect.ValueOf(v))
	fmt.Println("value3:", v.Interface().(MyInt))*/
	type a struct {
		name string
	}

	A := a{"wff"}
	Print(A)
}
